#include"Processbar.h"
#include<string.h>
#include<unistd.h>
#define Length 101
#define Style  '#'

const char* symbol="|\\-/";

void ProcBar(double total, double current)
{

  char bar[Length];
  memset(bar,'\0', sizeof(bar));
  
  int str = strlen(symbol);
  

  int cnt = 0;//表示百分比
  double rate = (current*100)/total;
  int loop_count = (int)rate;
  while(cnt <= loop_count)
  {
    bar[cnt++]=Style;
    //usleep(10000);
    //sleep(1);
  }
  printf("[%-100s][%1.lf%%][%c]\r",bar,rate,symbol[cnt%str]);
  fflush(stdout);
 // printf("\n");
}

